package ent

import (
	"elegantGo/chapter17/oo"
)

func (entVip *Vip) Mapper() oo.Vip {
	if entVip == nil {
		return nil
	}

	ooVip := oo.NewVip()
	ooVip.SetID(entVip.ID)
	ooVip.SetCategory(entVip.Category)
	ooVip.SetName(entVip.Name)
	ooVip.SetPrice(entVip.Price)
	ooVip.SetDuration(entVip.Duration)
	return ooVip
}

func (entVips Vips) Mapper() oo.Vips {
	size := len(entVips)
	ooVips := make(oo.Vips, size)
	for i := 0; i < size; i++ {
		ooVips[i] = entVips[i].Mapper()
	}
	return ooVips
}
